package chapter2;

public class Division {
    public static void main(String[] args) {
        int i1 = 1;
        int i2 = 0;
        String s = "整形数据相除，0做除数";
        try{
            int r = i1/i2;
            s+="没有异常";
        }catch (ArithmeticException e){
            s+="产生异常";
        }
        System.out.println(s);
        s ="整形数据求余，0做除数";
        try{
            int r = i1 % i2;
            s+="没有异常";
        }catch (ArithmeticException e){
            s+="产生异常";
        }
        System.out.println(s);
        float f1 = 1f;
        float f2 = 0f;
        s="浮点型数据相除，0做除数";
        try {
            float r = f1/f2;
            s+="没有异常";
        }catch (ArithmeticException e){
            s+="产生异常";
        }
        System.out.println(s);
        s="浮点型数据相除，0做除数";
        try {
            float r = f1 % f2 ;
            s+="没有异常";
        }catch (ArithmeticException e){
            s+="产生异常";
        }
        System.out.println(s);
    }
}
